<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</body>
<script>
    //1 Array.of 函数 将一组值转换为数组
    // let arr = Array.of(1,2,3,4,5,6);
    // console.log(arr); //[1,2,3,4,5,6]
    var str = "将一组数值转为数组"
    console.log(Array.of(str)); //["将一组数值转为数组"]
    //2 Array.from 函数 将伪数组对象或者可遍历对象转换为真数组
     var lilist = document.querySelectorAll("li");
     console.log(lilist); //NodeList(3) [li, li, li, callee: ƒ, Symbol(Symbol.iterator): ƒ]
     console.log(Array.from(lilist)); //[li, li, li]
     console.log(Array.from(str));  //["将", "一", "组", "数", "值", "转", "为", "数", "组"]
     // 数组深拷贝 传值
     var arr = [1,2,3,4];
     var arr1 = Array.from(arr);
     arr1.push(5);
     console.log(arr1); //[1,2,3,4,5]
     console.log(arr); //[1,2,3,4]
     //3 find 函数 查找数组中满足条件的第一个元素，找到返回元素，找不到返回undefined
     var value = arr.find(function(item,index){
        return item > 2; //返回值为true时，停止查找

     })
     console.log(value); //3
     //4 filter: 创建一个新数组，返回符合条件的所有元素
     var value1 = arr.filter(function(item,index){
         return item > 2; 
     })
     console.log(value1); //[3,4]
     //5 findIndex 查找数组中满足条件的第一个元素的索引，找到返回索引，找不到返回-1
     var index = arr.findIndex(function(item,index){
         return item > 4; //返回值为true时，停止查找
     })
     console.log(index); //-1
     //6 includes 判断数组中是否包含某个元素，包含返回true，不包含返回false
     console.log(arr.includes(3)); //true
     console.log(arr.includes(5)); //false
     //7 fill 填充数组，将数组中的元素填充为指定的值 不包括终止索引
     arr.fill(10,2,4); //从索引2开始，到索引4结束，填充为10
     console.log(arr); //[1,2,10,10]
</script>
<script>
     
</script>
</html>